package com.zzsy.carosshopprojects.activitys.home.mainpage.member.memberconsum.order;

import android.app.Activity;

import com.king.base.util.ToastUtils;
import com.zzsy.carosshopprojects.base.BaseViewMode;
import com.zzsy.carosshopprojects.bean.ActivityBean;
import com.zzsy.carosshopprojects.network.RequestUtils;
import com.zzsy.carosshopprojects.network.Utils.MyObserver;

import java.util.List;
import java.util.Map;

import androidx.lifecycle.MutableLiveData;

public class ActivityListMode extends BaseViewMode {

    private MutableLiveData<List<ActivityBean>> liveData;//活动

    public MutableLiveData<List<ActivityBean>> getliveData() {
        if (liveData == null)
            liveData = new MutableLiveData<>();
        return liveData;
    }

    /**
     * 获取活动折扣
     *
     * @param context
     */
    public void getActivityList(Activity context, Map<String, String> map) {

        RequestUtils.GetActivity(context, map, new MyObserver<List<ActivityBean>>(context) {
            @Override
            public void onSuccess(List<ActivityBean> result) {
                liveData.postValue(result);
            }

            @Override
            public void onFailure(Throwable e, String errorMsg, int code) {
                ToastUtils.showToast(context.getApplicationContext(), errorMsg);
            }
        });

    }
}
